/**
 * 
 */
package com.cipe.cmrs.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterRegistry;

import com.cipe.cmrs.bean.CodeDescriptionBean;
import com.cipe.cmrs.model.AccountCode;

/**
 * @author Incepio
 * 
 */
public class AccountCodeToCodeDescriptionBean implements Converter<AccountCode, CodeDescriptionBean> {

	private ConverterRegistry converterRegistry;

	/**
	 * @param converterRegistry
	 *            the converterRegistry to set
	 */
	public void setConverterRegistry(ConverterRegistry converterRegistry) {
		this.converterRegistry = converterRegistry;
	}

	public void init() {
		converterRegistry.addConverter(this);
	}

	public CodeDescriptionBean convert(AccountCode source) {
		CodeDescriptionBean bean = null;
		if (source != null) {
			bean = new CodeDescriptionBean();
			bean.setId(source.getId());
			bean.setCode(source.getAccountCode());
			bean.setDescription(source.getDescription());
			bean.setAccountStatus(source.getAccountStatus());
		}
		return bean;
	}

}
